package com.newlink.building.common_base.activities

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import android.view.View
import com.newlink.building.common_base.base.NL_BaseActivity
import com.newlink.building.common_base.databinding.ActivityGuideBinding

/**
 * @Author: Jake
 * @Date: 2024-09-25
 * @Description:
 */
class NL_GuideActivityNL : NL_BaseActivity() {

    private lateinit var mViewBinding: ActivityGuideBinding

    override fun attachLayoutRes(): View? {
        mViewBinding = ActivityGuideBinding.inflate(layoutInflater)
        return mViewBinding.root
    }

    override fun initData() {
    }

    override fun initView() {
        mViewBinding.guideBtnGot.setOnClickListener {
            isFirstUse = false //设置不再显示
            finish()
        }
        mViewBinding.guideBtnGoSettings.setOnClickListener {
            val intent =
                Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName"))
            startActivity(intent)
        }

        mViewBinding.guideBtnGoSettings2.setOnClickListener {
            goIntentSetting(this@NL_GuideActivityNL)
        }
    }

    private fun goIntentSetting(activity: Activity) {
        val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
        val uri = Uri.fromParts("package", activity.packageName, null)
        intent.data = uri
        try {
            activity.startActivity(intent)
        } catch (e: java.lang.Exception) {
            e.printStackTrace()
        }
    }

    override fun onBackPressed() {

    }
}